﻿@using AVCare.LMS.Util;
@model AVCare.LMS.Web.Models.SharedFileModel
@{                                                               
    ViewBag.Title = LanguageHelper.GetString("message.softname");
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section head{
    <link href="@Url.Content("~/Content/storage.css")" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery.prompt.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/selectMuliteRow.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery.popMenu.js")"></script>
    <script type="text/javascript">
        var rowTool = null;
        jQuery(function ($) {
            rowTool = new selectMuliteRow();
            rowTool.selectedRowStyle = "selectedRowStyle";
            var isEdit = false;
            $("#fileList ul li:odd").addClass("odd");   
            $("#fileList ul li:even").addClass("even");
            $("#fileList ul li:last").css({"border-bottom":"1px solid #51B1E1"});
           
            $("#fileList ul li[value]").click(function(){
                if(rowTool.selectRow(this)){
                    $.ajax({
                        type: "post",
                        url:"@Url.Action("RenameFile", "Disk")".replace("RenameFile",this.option), 
                        async: true,
                        cache: false,
                        data: {id:this.id},
                        success:function(msg){
                            if(msg.type == "folder"){                                                                              
                                $("#folderInfo").find("#foldername").text("名称：" + msg.name); 
                                $("#folderInfo").find("#username").text("用户：" + msg.user);
                                $("#folderInfo").show();
                                $("#fileInfo").hide();
                            }
                            if(msg.type == "file"){ 
                                $("#fileInfo").find("#filename").text("文件名：" + msg.name);          
                                $("#fileInfo").find("#modifydate").text("修改时间：" + msg.lastEditTime);
                                $("#fileInfo").find("#size").text("大小：" + msg.size);     
                                $("#fileInfo").find("#md5").text("MD5：" + msg.md5);
                                $("#fileInfo").find("#username").text("用户：" + msg.user);
                                $("#folderInfo").hide();
                                $("#fileInfo").show();
                            }
                        }
                    });
                }
            });
        });
    </script>
}
<div id="main">
    <div id="right">
        @{Html.RenderAction("LoginPartial", "User");}
        <div class="fileInfo" id="diskInfo">
            <span class="infoTitle">空间信息</span>
            <ul class="detail">
                <li>用户名：</li>
                <li>总大小：</li>
                <li>可用空间：</li>
            </ul>
        </div>
        <div class="fileInfo" id="fileInfo" style="display: none;">
            <span class="infoTitle">文件信息</span>
            <ul class="detail">
                <li id="filename"></li>
                <li id="modifydate"></li>
                <li id="size"></li>
                <li id="md5"></li>
                <li id="username"></li>
            </ul>
        </div>
        <div class="fileInfo" id="folderInfo" style="display: none;">
            <span class="infoTitle">文件夹信息</span>
            <ul class="detail">
                <li>文件夹</li>
                <li id="foldername"></li>
                <li id="username"></li>
            </ul>
        </div>
        <div class="fileInfo" style="display: none;">
            <span class="infoTitle">共享信息</span>
            <ul class="detail">
                <li>共享方式：</li>
            </ul>
        </div>
    </div>
    <div id="container">
        <div id="tools">
            
        </div>
        <div id="fileList">
            <div id="header">
            </div>
            <ul>
                <li><a href="/Disk/SharedFolder" title="返回根目录" class="whiteColor">
                    <img src="@Url.Content("~/content/img/fti/folder.png")" class="fileIcon" />.</a></li>                                                                                            
                <li><a href="@Url.Action("SharedFolder", "Disk", new { id = Model.ParentID })" title="返回上级目录" class="whiteColor">
                    <img src="@Url.Content("~/content/img/fti/folder.png")" class="fileIcon" />..</a></li>
                @{
                    var i = 0;     
                }
                @foreach (var item in Model.Folders)
                {
                    <li class="folder" title="@item.folder.Name" option="FolderInfo" id="@item.folder.ID" value="@i" >
                        <a href="@Url.Action("SharedFolder", "Disk", new { id = item.folder.ID })" class="whiteColor">
                            <img src="@Url.Content("~/content/img/fti/folder.png")" class="fileIcon" />@item.folder.Name</a>
                    </li>
                    i++;
                }
                @foreach (var item in Model.Files)
                {
                    <li class="file" title="@item.FileName" option="FileInfo" id="@item.ID" value="@i"  >
                        <a href="@Url.Action("Downdoad", "Disk", new { id = item.ID })" class="whiteColor">
                            <img src="@{
                    string path = Url.Content("~/content/img/fti/" + item.FileName.Substring(item.FileName.LastIndexOf(".") + 1) + ".png");
                    if (File.Exists(Server.MapPath(path)))
                    {
                        @path;
                    }
                    else
                    {
                        @Url.Content("~/content/img/fti/folder.png");
                    }}" class="fileIcon" />@item.FileName</a> </li>
                    i++;
                }
            </ul>
        </div>
        <div id="bottom">
        </div>
    </div>
</div>
                                                                                            